package com.med.meddataintegrator.doctor.controller;

import com.med.meddataintegrator.common.basic.response.JsonResult;
import com.med.meddataintegrator.common.pojo.dto.doctor.DoctorParam;
import com.med.meddataintegrator.common.pojo.dto.doctor.DoctorQueryParams;
import com.med.meddataintegrator.common.pojo.vo.doctor.DoctorVo;

import com.med.meddataintegrator.doctor.service.doctorService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/docker")
@Api(tags = "docker")
public class doctorController {

    @Autowired
    private doctorService doctorservice;
    @GetMapping("/list")
    public JsonResult selectDoctor( DoctorQueryParams doctorQueryParams){
        log.debug("查询医生：{}",doctorQueryParams);
        List<DoctorVo> list = doctorservice.selectDoctor(doctorQueryParams);
        return JsonResult.ok(list);
    }

    @GetMapping("select/{id}")
    public JsonResult selectByIdDoctor(@PathVariable Long id){
        log.debug("查询医生：{}",id);
        DoctorVo doctorVo = doctorservice.selectDoctorById(id);
        return JsonResult.ok(doctorVo);
    }

    @PostMapping("update")
    public JsonResult updateDoctor(@RequestBody DoctorParam doctorParam){
        log.debug("更新医生：{}",doctorParam);
        doctorservice.updateDoctor(doctorParam);
        return JsonResult.ok();
    }

    @PostMapping("del/{id}")
    public JsonResult delDoctor(@PathVariable Long id){
        log.debug("删除医生：{}",id);
        doctorservice.delDoctor(id);
        return JsonResult.ok();
    }
    @PostMapping("add")
    public JsonResult addDoctor(@RequestBody DoctorParam doctorParam){
        log.debug("添加医生：{}",doctorParam);
        doctorservice.addDoctor(doctorParam);
        return JsonResult.ok();
    }
}

